#ifndef __CMD_H
#define __CMD_H

#include "common.h"

#define CFG_CBSIZE  256
#define CFG_PROMPT                      "cIot"         /* Monitor Command Prompt   */

#define CMD_FLAG_REPEAT     0x0001     /* repeat last command      */
#define CMD_FLAG_BOOTD      0x0002     /* command is from bootd   */
#define CFG_MAXARGS         16

#define CMD_MODE_USER       (1U << 0)
#define CMD_MODE_CONFIG     (1U << 1)
#define CMD_MODE_EQUIPMENT  (1U << 2)
#define CMD_MODE_DEBUG      (1U << 3)

#define CMD_MANU_USER       CMD_MODE_USER
#define CMD_MANU_CONFIG     (CMD_MODE_CONFIG | CMD_MODE_USER)
#define CMD_MANU_EQUIPMENT  (CMD_MODE_EQUIPMENT | CMD_MODE_USER)
#define CMD_MANU_DEBUG      (CMD_MODE_DEBUG | CMD_MODE_EQUIPMENT\
                             | CMD_MODE_CONFIG | CMD_MODE_USER)


typedef struct CMD_TBL_ITEM
{
    char *name;
    s32 maxargs;
    SYS_ERR_E (*cmd)(struct CMD_TBL_ITEM *, s32, s32, char *[]);
    char *usage;
    char *help;
    void *pArg;
    char manumode;
    
}CMD_TBL_ITEM_S;


#define MK_CMD_TBL_ENTRY(name,maxargs,cmd,usage,help,pArg,manumode)  \
        {name,maxargs,cmd,usage,help,pArg,manumode}




#define CMD_TBL_MD      MK_CMD_TBL_ENTRY("md", 4, CMD_MemDump, "Memory dump - md [width][Addr][size]",  NULL, NULL, CMD_MANU_DEBUG),
#define CMD_TBL_MM      MK_CMD_TBL_ENTRY("mm", 4, CMD_MemSet, "Memory set - mm [width][Addr][Val]",  NULL, NULL, CMD_MANU_DEBUG),
#define CMD_TBL_HELP    MK_CMD_TBL_ENTRY("help",2, CMD_DoHelp, "Help [cmd]", NULL, NULL, CMD_MANU_USER),
#define CMD_TBL_LOGIN   MK_CMD_TBL_ENTRY("login", 2, CMD_Login, "Login Admin mode - login [password]", NULL, NULL, CMD_MANU_USER),
#define CMD_TBL_LOGOUT  MK_CMD_TBL_ENTRY("logout", 1, CMD_Logout, "user mode  - logout", NULL, NULL, CMD_MANU_USER),

SYS_ERR_E CMD_MemDump(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
SYS_ERR_E CMD_MemSet(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
SYS_ERR_E CMD_DoHelp(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
SYS_ERR_E CMD_Login(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
SYS_ERR_E CMD_Logout(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);        


void CMD_MainLoop(void *pvParameters);



/* User Cmd */
extern SYS_ERR_E CMD_TaskCntShow(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
#define CMD_TBL_TASK_CNT  MK_CMD_TBL_ENTRY("taskcnt", 1, CMD_TaskCntShow, "all task excute counts - taskcnt", NULL, NULL, CMD_MANU_USER),
extern SYS_ERR_E CMD_DataShow(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
#define CMD_TBL_DATA  MK_CMD_TBL_ENTRY("data", 1, CMD_DataShow, "all data show - data", NULL, NULL, CMD_MANU_USER),
extern SYS_ERR_E CMD_BSP_Ctrl(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
#define CMD_TBL_BSP  MK_CMD_TBL_ENTRY("bspctrl", 3, CMD_BSP_Ctrl, "ctrl dev - bspctrl", NULL, NULL, CMD_MANU_USER),
extern SYS_ERR_E CMD_OnenetShow(CMD_TBL_ITEM_S *cmdtp, s32 flag, s32 argc, char *argv[]);
#define CMD_TBL_ONENET  MK_CMD_TBL_ENTRY("onenet", 1, CMD_OnenetShow, "ctrl dev - bspctrl", NULL, NULL, CMD_MANU_USER),

#endif
